Computer Science Related Others Courses AvailableThe Best Codder.blogspot.com

Programs for printing pyramid patterns in Python

Programs for printing pyramid patterns in Python
1 min read

# Function to demonstrate printing pattern

def pypart(n):

     

    # outer loop to handle number of rows

    # n in this case

    for i in range(0, n):

     

        # inner loop to handle number of columns

        # values changing acc. to outer loop

        for j in range(0, i+1):

         

            # printing stars

            print("* ",end="")

      

        # ending line after each row

        print("\r")

 

# Driver Code

n = 5

pypart(n)

Output

* * 

* * * 

* * * * 

* * * * *  

You may like these posts

Post a Comment

© 2025Python . The Best Codder All rights reserved. Distributed by